package framework

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/driver/desktop"
	"go-CodeToolUi/core"
	"go-CodeToolUi/inner_resources/_icon_"
)

func CombinationFramework() {
	Tray()
	core.TopWin.SetIcon(_icon_.ResourceIconPng)
	core.TopWin.SetTitle("工具")
	core.TopWin.Resize(fyne.NewSize(1200, 800))
	core.TopWin.CenterOnScreen()

	content := container.NewBorder(TopJieGou, nil, nil, nil, CenterJieGou)
	core.TopWin.SetContent(content)
	core.TopWin.ShowAndRun()
}

// 托盘
func Tray() {
	//设置系统托盘
	if desk, ok := core.AppCore.(desktop.App); ok {
		m := fyne.NewMenu("MyApp",
			fyne.NewMenuItem("Show", func() {
				core.TopWin.Show()
			}))
		desk.SetSystemTrayMenu(m)
		desk.SetSystemTrayIcon(_icon_.ResourceIconPng)

	}
	//设置关闭拦截,这样点击关闭按钮时,只是隐藏窗口,只要通过系统托盘关闭才会真正关闭
	core.TopWin.SetCloseIntercept(func() {
		core.TopWin.Hide()
	})
}
